//
//  ToolsTests.m
//  ToolsTests
//
//  Created by 吴浪 on 16/3/10.
//  Copyright © 2016年 吴浪. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "NSData+AES.h"
#import "UIDevice+Hardware.h"
#import "LYLib.h"
#import <objc/message.h>
//void objc_msgSend(id, SEL, ...);

@interface ToolsTests : XCTestCase

@end

@implementation ToolsTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testDES {
    
//    NSUInteger a = NSDataBase64Encoding64CharacterLineLength;
//    NSUInteger b = NSDataBase64Encoding76CharacterLineLength;
//    NSUInteger c = NSDataBase64EncodingEndLineWithCarriageReturn;
//    NSUInteger d = NSDataBase64EncodingEndLineWithLineFeed;
    NSString *DESKey = @"abc";
    NSString *str = @"我是一个伟人！";
    NSString *strDES = [str desEncryptWithKey:DESKey];
    NSString *strS = [strDES desDecryptWithKey:DESKey];
}

- (void)testAES {
    NSString *str = @"我是一个伟人！";
    NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
    NSData *dataAES = [data aes256EncryptWithKey:@"abc"];
    
    NSData *data1 = [dataAES aes256DecryptWithKey:@"abc"];
    NSString *str1 = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];
}

- (void)testMD5 {
    NSString *str = @"我是一个伟人！";
    NSString *md5 = str.md5String;
    XCTAssertNotNil(md5, @"Str MD5加密失败");
}

- (void)testBankCode {
    NSString *str = @"6";
    BOOL isMatch = [str checkBankCard];
    XCTAssert(isMatch, @"Str 不是一个银卡号");
}

- (void)testPostCode {
    NSString *str = @" 000000";
    BOOL isMatch = [str checkPostcode];
    SEL sel = @selector(hasSuffix:);
//    id reaut = objc_msgSend(str, sel, @"0");
    XCTAssert(isMatch, @"Str 不是一个邮编");
}

- (void)testEmal {
    NSString *str = @"8352.+-+-+^-+_+%%%%%%%%%%%_+_+_--+-6_3%@qq.com";
    BOOL isMatch = [str checkEmail];
    XCTAssert(isMatch, @"Str 不是一个邮箱");
}

- (void)testShenFenZheng {
    NSString *str = @" 61052119911231249x ";
    BOOL isMacth = [str checkShenFenZheng];
    XCTAssert(isMacth, @"Str 不是身份证");
}

- (void)testStr {
    NSString *str = @" 师德师风 水电费 是的发 送到 ";
    str = [str stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]];
}

- (void)testNum {
    
    double num = 1234357561.1234523;
    NSString *numStr = [NSString getFormatForNum:@(num) count:3 separator:@"!" flag:YES];
}

- (void)testData {
//    NSString *str = [UIDevice uniqueGlobalDeviceIdentifier];
    CGFloat dianchi = [UIDevice getBatteryQuantity];
    
    NSUInteger total1 = [UIDevice totalDiskSpaceBytes];
//    NSUInteger total2 = [UIDevice getTotalDiskSize];
    NSUInteger total3 = [UIDevice freeDiskSpaceBytes];
    
//    NSUInteger total4 = [UIDevice totalDiskSpaceBytes];
//        NSUInteger total1 = [UIDevice freeMemoryBytes];
//        NSUInteger total2 = [UIDevice getFreeMemorySize];
//        NSUInteger total3 = [UIDevice freeMemoryBytes];
//        NSUInteger total4 = [UIDevice totalDiskSpaceBytes];
    
    NSString *df = [NSString fileSizeToString:total1];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
    NSArray *array = @[@"水电费", @"呵呵", @"是大法官"];
    NSLog(@"array=%@dsf", array);
    
    NSString *str = @"我是test的一个依据";
    NSLog(@"str=%@dsf", str);
    
    NSDictionary *dict = @{@"12" : @"我", @"13" : @"呵呵", @"14" : @"天下"};
    NSLog(@"dict=%@sdf", dict);
    
}

- (void)testImage {
    UIImage *image = [UIImage imageNamed:@"test1"];
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300.0, 300.0)];
        //    imageView.image = ;
        
        imageView.backgroundColor = [UIColor blueColor];
        [imageView setImageToBlur:[UIImage imageNamed:@"test1"] blurRadius:200.0 completionBlock:NULL];
    }];
}

@end
